import {UserActions} from './user';

const initialState = {
  count: 0,
  current: 0,
  total: 0,
  results: [],
  roleList: [],
};

export const AccountListActions = {
  ACCOUNT_LIST_UPDATE: 'account_list_update',
};

export function updateAccountList(payload) {
  return {
    type: AccountListActions.ACCOUNT_LIST_UPDATE,
    payload,
  };
}

export default function accountList(state = initialState, action) {
  switch (action.type) {
    case AccountListActions.ACCOUNT_LIST_UPDATE:
      return {...state, ...action.payload};
    case UserActions.USER_SIGN_OUT:
      return {
        count: 0,
        current: 0,
        total: 0,
        results: [],
        roleList: [],
      };
    default:
      return state;
  }
}
